﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace Bamboo.Core.Common
{
    public class DateUtil
    {
        public static DateTime NULL_DATE = new DateTime(1970, 1, 1);
        public static bool IsNullDate(DateTime date)
        {
            return (date.Year == NULL_DATE.Year && date.Month == NULL_DATE.Month && date.Day == NULL_DATE.Day);
        }
        public static DateTime GetDateFromString(string dateValue, string dateFormat)
        {
            IFormatProvider culture = new CultureInfo("en-US", true);
            return DateTime.ParseExact(dateValue, dateFormat, culture);
        }
        public static string GetStringFromDate(DateTime date, string dateFormat)
        {
            return date.ToString(dateFormat);
        }
    }
}
